<template>
  <div class='order'>
    <Film-title title='提交订单'></Film-title>
    <van-card
      desc="138元"
      title="武庚纪银饰系列"
      thumb="//p1.meituan.net/movie/098b35201ff41622b215eb8dd186d95c112761.jpg@750w_750h_2e.webp"
    />
    <section class="goods-child-wrapper">
      <div class="goods-child">
        <div class="header">类型:</div><span class="goods-child-item goods-child-item-selected">白菜戒指</span>
      </div>
    </section>
    <van-cell-group class="van_cell-ge">
      <van-cell title="数量:" />
      <van-stepper
        v-model="value"
        class="step"
      />
    </van-cell-group>

    <van-coupon-cell
      :coupons="coupons"
      :chosen-coupon="chosenCoupon"
      @click="showList = true"
    />
    <!-- 优惠券列表 -->
    <van-popup
      v-model="showList"
      round
      position="bottom"
      style="height: 90%; padding-top: 4px;"
    >
      <van-coupon-list
        :coupons="coupons"
        :chosen-coupon="chosenCoupon"
        :disabled-coupons="disabledCoupons"
        @change="onChange"
        @exchange="onExchange"
      />
    </van-popup>
    <div class="contain">
      <van-cell-group>

        <van-cell
          title="运费:"
          value="包邮"
        />
        <van-cell
          title="总价:"
          value="138元"
        />
      </van-cell-group>
    </div>
    <van-address-edit
      class="address"
      :area-list="areaList"
      show-postal
      save-button-text="提交订单"
      show-set-default
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
    >
    </van-address-edit>
    <!-- <section class="buy-button-wrapper"><a
        role="button"
        class="am-button buy-button"
        aria-disabled="false"
      ><span>提交订单</span></a></section> -->
  </div>
</template>
<script>
import { Toast } from 'vant'
const coupon = {
  available: 1,
  condition: '无使用门槛\n最多优惠12元',
  reason: '',
  value: 150,
  name: '优惠券名称',
  startAt: 1489104000,
  endAt: 1514592000,
  valueDesc: '1.5',
  unitDesc: '元'
}
const areaList = {
  province_list: {
    110000: '北京市',
    120000: '天津市'
  },
  city_list: {
    110100: '北京市',
    120100: '天津市'
  },
  county_list: {
    110101: '东城区',
    110102: '西城区'
  }
}
export default {
  data: () => ({
    value: 1,
    chosenCoupon: -1,
    coupons: [coupon],
    disabledCoupons: [coupon],
    areaList,
    searchResult: []

  }),
  methods: {
    onChange(index) {
      this.showList = false
      this.chosenCoupon = index
    },
    onExchange(code) {
      this.coupons.push(coupon)
    },
    onSave() {
      Toast('save')
    },
    onDelete() {
      Toast('delete')
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: '黄龙万科中心',
            address: '杭州市西湖区'
          }
        ]
      } else {
        this.searchResult = []
      }
    }
  }
}
</script>
<style lang="scss">
.order {
  .van-card__title {
    display: block;
    font-size: 16px;
    padding-top: 5px;
    font-weight: 400;
    color: #333;
    line-height: 1;
    width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .van-card__desc {
    display: block;
    font-size: 16px;
    color: #ef4238;
    font-weight: 700;
    margin-top: 10px;
  }
  .van_cell-ge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .step {
      width: 160px;
    }
  }
  .contain {
    .van-cell__value {
      span {
        font-size: 15px;
        font-weight: 400;
        color: #e54847;
      }
    }
  }
  .van-address-edit {
    padding: 0px;
    margin-top: 10px;
  }
  .goods-child-wrapper {
    margin: 15px;
    .goods-child {
      .header {
        font-size: 14px;
        font-weight: 700;
      }
      .goods-child-item {
        font-size: 14px;
        display: inline-block;
        margin: 10px 10px 0 0;
        padding: 1px 10px;
        background-color: #ddd;
        border-radius: 15px;
        color: #fff;
      }
      .goods-child-item-selected {
        background-color: #f90;
      }
    }
  }
  .buy-button-wrapper {
    overflow: hidden;
    background-color: #f0efed;
    .am-button {
      position: relative;
      border: none;
      display: block;
      outline: 0 none;
      box-sizing: border-box;
      padding: 0;
      text-align: center;
      font-size: 18px;
      height: 47px;
      line-height: 47px;
      overflow: hidden;
      text-overflow: ellipsis;
      word-break: break-word;
      white-space: nowrap;
      color: #000;
      background-color: #fff;
      border: 1px solid #ddd;
      border-radius: 5px;
    }
    .buy-button {
      font-size: 18px;
      line-height: 47px;
      height: 47px;
      margin: 10px;
      overflow: hidden;
      background-color: #f90;
      color: #fff;
    }
  }
}
</style>
